const {
  DataTypes
} = require('sequelize');
module.exports = sequelize => {
  const attributes = {
    id: {
      type: DataTypes.INTEGER(10).UNSIGNED,
      allowNull: false,
      defaultValue: null,
      primaryKey: true,
      autoIncrement: true,
      comment: "自增id",
      field: "id"
    },
    title: {
      type: DataTypes.CHAR(60),
      allowNull: false,
      defaultValue: "",
      primaryKey: false,
      autoIncrement: false,
      comment: "标题",
      field: "title"
    },
    article_category_id: {
      type: DataTypes.INTEGER(10).UNSIGNED,
      allowNull: false,
      defaultValue: "0",
      primaryKey: false,
      autoIncrement: false,
      comment: "文章分类",
      field: "article_category_id"
    },
    title_color: {
      type: DataTypes.CHAR(7),
      allowNull: false,
      defaultValue: "",
      primaryKey: false,
      autoIncrement: false,
      comment: "标题颜色",
      field: "title_color"
    },
    jump_url: {
      type: DataTypes.CHAR(255),
      allowNull: false,
      defaultValue: "",
      primaryKey: false,
      autoIncrement: false,
      comment: "跳转url地址",
      field: "jump_url"
    },
    is_enable: {
      type: DataTypes.INTEGER(3).UNSIGNED,
      allowNull: false,
      defaultValue: "1",
      primaryKey: false,
      autoIncrement: false,
      comment: "是否启用（0否，1是）",
      field: "is_enable"
    },
    content: {
      type: DataTypes.TEXT,
      allowNull: true,
      defaultValue: null,
      primaryKey: false,
      autoIncrement: false,
      comment: "内容",
      field: "content"
    },
    images: {
      type: DataTypes.TEXT,
      allowNull: true,
      defaultValue: null,
      primaryKey: false,
      autoIncrement: false,
      comment: "图片数据（一维数组json）",
      field: "images"
    },
    images_count: {
      type: DataTypes.INTEGER(3).UNSIGNED,
      allowNull: false,
      defaultValue: "0",
      primaryKey: false,
      autoIncrement: false,
      comment: "图片数量",
      field: "images_count"
    },
    access_count: {
      type: DataTypes.INTEGER(10).UNSIGNED,
      allowNull: false,
      defaultValue: "0",
      primaryKey: false,
      autoIncrement: false,
      comment: "访问次数",
      field: "access_count"
    },
    is_home_recommended: {
      type: DataTypes.INTEGER(3).UNSIGNED,
      allowNull: false,
      defaultValue: "0",
      primaryKey: false,
      autoIncrement: false,
      comment: "是否首页推荐（0否, 1是）",
      field: "is_home_recommended"
    },
    seo_title: {
      type: DataTypes.CHAR(100),
      allowNull: false,
      defaultValue: "",
      primaryKey: false,
      autoIncrement: false,
      comment: "SEO标题",
      field: "seo_title"
    },
    seo_keywords: {
      type: DataTypes.CHAR(130),
      allowNull: false,
      defaultValue: "",
      primaryKey: false,
      autoIncrement: false,
      comment: "SEO关键字",
      field: "seo_keywords"
    },
    seo_desc: {
      type: DataTypes.CHAR(230),
      allowNull: false,
      defaultValue: "",
      primaryKey: false,
      autoIncrement: false,
      comment: "SEO描述",
      field: "seo_desc"
    },
    add_time: {
      type: DataTypes.INTEGER(10).UNSIGNED,
      allowNull: false,
      defaultValue: "0",
      primaryKey: false,
      autoIncrement: false,
      comment: "添加时间",
      field: "add_time"
    },
    upd_time: {
      type: DataTypes.INTEGER(10).UNSIGNED,
      allowNull: false,
      defaultValue: "0",
      primaryKey: false,
      autoIncrement: false,
      comment: "更新时间",
      field: "upd_time"
    }
  };
  const options = {
    tableName: "sxo_article",
    comment: "",
    indexes: [{
      name: "title",
      unique: false,
      type: "BTREE",
      fields: ["title"]
    }, {
      name: "is_enable",
      unique: false,
      type: "BTREE",
      fields: ["is_enable"]
    }, {
      name: "access_count",
      unique: false,
      type: "BTREE",
      fields: ["access_count"]
    }, {
      name: "image_count",
      unique: false,
      type: "BTREE",
      fields: ["images_count"]
    }, {
      name: "article_category_id",
      unique: false,
      type: "BTREE",
      fields: ["article_category_id"]
    }]
  };
  const SxoArticleModel = sequelize.define("sxo_article_model", attributes, options);
  return SxoArticleModel;
};